/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EdgePanel.java
 *
 * Created on Mar 29, 2011, 10:50:40 PM
 */

package view;

import java.awt.event.ActionListener;
import javax.swing.event.ChangeListener;

/**
 *
 * @author borysfan
 */
public class EdgePanel extends javax.swing.JPanel {

    /** Creates new form EdgePanel */
    public EdgePanel() {
        initComponents();
    }

   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSeparator1 = new javax.swing.JSeparator();
        title_edge_label = new javax.swing.JLabel();
        lock_edge_label = new javax.swing.JLabel();
        name_edge_label = new javax.swing.JLabel();
        edge_name = new javax.swing.JTextField();
        edge_length = new javax.swing.JTextField();
        edge_lock = new javax.swing.JCheckBox();
        vmax_edge_label = new javax.swing.JLabel();
        edge_vmax = new javax.swing.JTextField();
        length_edge_label = new javax.swing.JLabel();
        edge_save = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        road = new javax.swing.JComboBox();
        weather = new javax.swing.JComboBox();
        traffic = new javax.swing.JComboBox();
        delete = new javax.swing.JButton();
        roadslider = new javax.swing.JSlider();
        weatherslider = new javax.swing.JSlider();
        intenLabel1 = new javax.swing.JLabel();
        intensLabel2 = new javax.swing.JLabel();
        roadslidervalue = new javax.swing.JTextField();
        weatherslidervalue = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        readSpeed = new javax.swing.JLabel();
        realTime = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();

        setMaximumSize(new java.awt.Dimension(358, 400));
        setPreferredSize(new java.awt.Dimension(358, 400));

        title_edge_label.setText("Właściwości:");

        lock_edge_label.setText("Blokada:");

        name_edge_label.setText("Nazwa:");

        vmax_edge_label.setText("Prędkość:");

        edge_vmax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edge_vmaxActionPerformed(evt);
            }
        });

        length_edge_label.setText("Długość:");

        edge_save.setText("Zapisz");

        jLabel1.setText("Warunki drogowe:");

        jLabel2.setText("Warunki pogodowe:");

        jLabel3.setText("Gęstość ruchu:");

        road.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"Idealne", "Remont", "Wypadek", "Utrudnienia w ruchu"}));
        road.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                roadActionPerformed(evt);
            }
        });

        weather.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Idealne", "Deszcz", "Śnieg", "Grad" , "Gołoledź", "Mgła"}));

        traffic.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mała", "Średnia", "Duża" }));

        delete.setText("Usuń");

        roadslider.setToolTipText("Przeciągnij aby wybrać natężenie");
        roadslider.setMaximum(100);
        roadslider.setMinimum(1);

        weatherslider.setToolTipText("Przeciągnij aby wybrać natężenie");
        weatherslider.setMaximum(100);
        weatherslider.setMinimum(1);

        intenLabel1.setText("Natężenie:");

        intensLabel2.setText("Natężenie:");

        roadslidervalue.setEditable(false);
        roadslidervalue.setText("000");

        weatherslidervalue.setEditable(false);
        weatherslidervalue.setText("000");

        jLabel4.setText("Prędkość rzeczywista:");

        jLabel5.setText("Czas:");

        readSpeed.setText("0");

        realTime.setText("0");

        jLabel8.setText("km/h");

        jLabel9.setText("min");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(title_edge_label)
                            .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 332, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(name_edge_label, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(40, 40, 40)
                                .addComponent(edge_name, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lock_edge_label, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(40, 40, 40)
                                .addComponent(edge_lock))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(length_edge_label, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(vmax_edge_label, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(40, 40, 40)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(edge_vmax)
                                    .addComponent(edge_length, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)))
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(intenLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(roadslider, 0, 0, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(roadslidervalue, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(intensLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(22, 22, 22)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(traffic, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(weather, 0, 180, Short.MAX_VALUE)
                                        .addComponent(road, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addComponent(weatherslider, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(weatherslidervalue, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(72, 72, 72)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(readSpeed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(realTime, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel8)
                                                .addComponent(jLabel9))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)))))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(delete, javax.swing.GroupLayout.PREFERRED_SIZE, 332, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(edge_save, javax.swing.GroupLayout.PREFERRED_SIZE, 332, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel4))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel5)))
                .addContainerGap(16, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(title_edge_label)
                .addGap(6, 6, 6)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(name_edge_label))
                    .addComponent(edge_name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(vmax_edge_label)
                    .addComponent(edge_vmax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(length_edge_label))
                    .addComponent(edge_length, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(lock_edge_label))
                    .addComponent(edge_lock))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(road, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(roadslidervalue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(roadslider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(weather, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(intenLabel1))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(intensLabel2))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(weatherslider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(weatherslidervalue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(traffic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel8)
                    .addComponent(readSpeed))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel9)
                    .addComponent(realTime))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                .addComponent(edge_save)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(delete)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void edge_vmaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edge_vmaxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_edge_vmaxActionPerformed

    private void roadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_roadActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_roadActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton delete;
    private javax.swing.JTextField edge_length;
    private javax.swing.JCheckBox edge_lock;
    private javax.swing.JTextField edge_name;
    private javax.swing.JButton edge_save;
    private javax.swing.JTextField edge_vmax;
    private javax.swing.JLabel intenLabel1;
    private javax.swing.JLabel intensLabel2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel length_edge_label;
    private javax.swing.JLabel lock_edge_label;
    private javax.swing.JLabel name_edge_label;
    private javax.swing.JLabel readSpeed;
    private javax.swing.JLabel realTime;
    private javax.swing.JComboBox road;
    private javax.swing.JSlider roadslider;
    private javax.swing.JTextField roadslidervalue;
    private javax.swing.JLabel title_edge_label;
    private javax.swing.JComboBox traffic;
    private javax.swing.JLabel vmax_edge_label;
    private javax.swing.JComboBox weather;
    private javax.swing.JSlider weatherslider;
    private javax.swing.JTextField weatherslidervalue;
    // End of variables declaration//GEN-END:variables

   

    public void setEdgeName(String name) {
      edge_name.setText(name);
    }

    public void setEdgeVMax(double vMax) {
        edge_vmax.setText(String.valueOf(vMax));
    }

    public void setEdgeLength(double lmax) {
        edge_length.setText(String.valueOf(lmax));
    }

   

    public void setEdgeLock(boolean lock) {
        edge_lock.setSelected(lock);
    }

 

    public String getEdgeName(){
        return edge_name.getText();
    }

    public String getEdgeVMax(){
        return edge_vmax.getText();
    }

    public String getEdgeLenght(){
        return edge_length.getText();
    }

   

    public boolean getEdgeLock(){
        return edge_lock.isSelected();
    }

    public int getTraffic(){
        return traffic.getSelectedIndex();
    }

    public void setTraffic(int traffic){
        this.traffic.setSelectedIndex(traffic);
    }

    public int getRoad(){
        return road.getSelectedIndex();
    }

    public void setRoad(int road){
        this.road.setSelectedIndex(road);
    }

    public int getWeather(){
        return weather.getSelectedIndex();
    }

    public void setWeather(int weather){
        this.weather.setSelectedIndex(weather);
}

    public int getWeatherSlider(){
        return weatherslider.getValue();
    }

    public void setWeatherSlider(int weatherslider){
        this.weatherslider.setValue(weatherslider);
    }

    public int getRoadSlider(){
        return roadslider.getValue();
    }

    public void setRoadSlider(int roadslider){
        this.roadslider.setValue(roadslider);
    }

     public void addSave(ActionListener listener) {
       edge_save.addActionListener(listener);
    }


    public void addDelete(ActionListener listener){
        delete.addActionListener(listener);
    }

    public void addWeatherComboBoxAction(ActionListener action){
        this.weather.addActionListener(action);
    }

    public void addRoadComboBoxAction(ActionListener action){
        this.road.addActionListener(action);
    }

    public void addRoadSliderAction(ChangeListener change){
        this.roadslider.addChangeListener(change);
    }

    public void addWeatherSliderAction(ChangeListener change){
        this.weatherslider.addChangeListener(change);
    }

    public int getSelectedWeatherIndex() {
        return weather.getSelectedIndex();
    }

    public int getSelectedRoadIndex() {
        return road.getSelectedIndex();
    }


    public void setWeatherSliderVisible(boolean b) {
        weatherslider.setVisible(b);
        intensLabel2.setVisible(b);
        weatherslidervalue.setVisible(b);
        updateUI();
    }

    public void setRoadSliderVisible(boolean b){
        roadslider.setVisible(b);
        intenLabel1.setVisible(b);
        roadslidervalue.setVisible(b);
        updateUI();
    }

    public void setRoadSliderValue(){
        this.roadslidervalue.setText(String.valueOf(this.roadslider.getValue()+"%"));
    }

    public void setWeatherSliderValue(){
        this.weatherslidervalue.setText(String.valueOf(this.weatherslider.getValue()+"%"));
    }

    public void setRealSpeed(String value){
        this.readSpeed.setText(value);
    }

    public void setRealTime(String value){
        this.realTime.setText(value);
    }

}
